package thread;

public class ExecutionOrderTest {
    int a =0;
    boolean flag =false;

    public void  writer(){
        a=1;
        flag = true;
    }

    public void reader(){
        if (flag){
            int i = a+1;
            System.out.println("i= " +i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        final ExecutionOrderTest test = new ExecutionOrderTest();
        new Thread(new Runnable() {
            @Override
            public void run() {
                test.writer();
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                test.reader();
            }
        }).start();

    }

}
